package imper.main.listener;

import imper.engine.entity.ArmyBoatType;
import imper.engine.entity.Country;
import imper.engine.util.ParameterManager;
import imper.engine.util.ProductionUtil;
import imper.graphic.ButtonListener;
import imper.graphic.event.ClickEvent;

public class AddBoatListener implements ButtonListener
{
	protected ArmyBoatType _ArmyBoatType;

	public AddBoatListener( ArmyBoatType pArmyBoatType )
	{
		this._ArmyBoatType = pArmyBoatType;
	}

	@Override
	public void click(ClickEvent pEvent)
	{
		Country country = ParameterManager.getInstance().getCountry();
		Integer value = country.getProdBoat().get(_ArmyBoatType.getId());
		if (value == null)
		{
			value = 0;
		}
		value++;
		if( ProductionUtil.isAutorise( _ArmyBoatType, value , country))
		{
			// verifier la conso
			country.getProdBoat().put(_ArmyBoatType.getId(), value);
		}
	}

}
